package com.smartrobot.smartrobot.activity;

import android.app.Instrumentation;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.MotionEvent;

import com.robotium.solo.Solo;
import com.smartrobot.smartrobot.view.ExListView;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ActiveActivityTest extends ActivityInstrumentationTestCase2<ActiveActivity> {

    private Solo solo;
    private ExListView circleListView;
    Instrumentation instrumentation;

    public ActiveActivityTest() {
        super(ActiveActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());

    }

    @Override
    public void tearDown() throws Exception {

        solo.finishOpenedActivities();

    }

    /**
     * 测试ui界面 是否具备以下元素
     * @throws Exception
     */
    public void testUI()throws Exception{



        //预期结果
        boolean expected = true;
        //实际的结果
        boolean result1 = solo.searchText("圈子动态");
        boolean result2 =  solo.searchButton("全世界");
        boolean result3 =  solo.searchButton("发布动态");

        assertEquals(expected,result1);
        assertEquals(expected,result2);
        assertEquals(expected,result3);


    }

    /**
     * 刷新我的圈子
     * @throws Exception
     */
    public void testRefashMyCircle()throws Exception{

        circleListView = getActivity().circleActiveListView;
        //预期结果
        boolean expected = true;
//        scrollVertical(circleListView,-50);
//        solo.scrollListToLine(circleListView,5);

//        solo.clickOnScreen(70, 70);
//        solo.drag(70, 70, 70, 150, 3);
        circleListView.scrollTo(0,-200);





        boolean result1 = solo.waitForText("没有了");


        assertEquals(expected,result1);


    }

    /**
     * 发布动态
     * @throws Exception
     */
//    public void testSendActive()throws Exception{
//
//        //预期结果
//        boolean expected = true;
//        solo.clickOnButton("发布动态");
//        solo.enterText(0,"只是自动化测试");
//        solo.clickOnText("分享到");
//        solo.clickOnCheckBox(1);
//        solo.goBack();
//        solo.clickOnButton("发布");
//
//        boolean result1 = solo.waitForText("发送成功");
//
//
//        assertEquals(expected,result1);
//
//
//    }






}